<template>
	<view class="" style="background-color: #f8f8f8;">
		<view class="" style="height: 26rpx;"></view>
		<view class="" style="background-color: #fff;padding: 0 30rpx;">
			<u-form :model="form" ref="uForm">
					<u-form-item label="标题" label-width="150">
						<u-input v-model="form.title" />
					</u-form-item>
					<!-- <u-form-item label="简介"><u-input v-model="form.intro" /></u-form-item> -->
					<u-form-item label="优先级" label-width="150">
						<u-input v-model="form.levelN" type="select" @click="show = true" />
						<u-select v-model="show" :list="list" @confirm="confirm"></u-select>
					</u-form-item>
					<u-form-item label="提醒日期" label-width="150">
						<u-input v-model="form.remindDate"  type="select" @click="show2 = true" />
						<u-picker v-model="show2" mode="time" :params="params" @confirm="confirm2"></u-picker>
					</u-form-item>
					<u-form-item label="内容" label-width="150">
						<u-input v-model="form.content" :type="type" :border="border" :height="height" :auto-height="autoHeight" />
					</u-form-item>
					<!-- <u-form-item label="水果">
						<u-checkbox-group>
							<u-checkbox v-model="item.checked" v-for="(item, index) in checkboxList" :key="index" :name="item.name">
								{{ item.name }}
							</u-checkbox>
						</u-checkbox-group>
					</u-form-item> -->
					<!-- <u-form-item label="味道">
						<u-radio-group v-model="radio">
							<u-radio v-for="(item, index) in radioList" :key="index" :name="item.name" :disabled="item.disabled">
								{{ item.name }}
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="开关"><u-switch slot="right" v-model="switchVal"></u-switch></u-form-item> -->
				</u-form>
		</view>
		<view class="" style="padding: 0 30rpx;position: absolute;bottom: 100rpx;width: 100%;">
			<u-button type="primary" shape="circle" @click="submit">提交</u-button>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			form: {
				title: '',
				content: '',
				level: '',
				levelN: '',
				remindDate: ''
			},
			show: false,
			show2: false,
			list: [
				{
					value: '1',
					label: '一般'
				},
				{
					value: '2',
					label: '紧急'
				}
			],
			value: '',
			type: 'textarea',
			border: true,
			height: 100,
			autoHeight: true,
			params: {
								year: true,
								month: true,
								day: true,
								hour: true,
								minute: true,
								second: true
							},
			radio: '',
			switchVal: false
		};
	},
	methods:{
		confirm(e) {
			console.log(e);
			this.form.levelN = e[0].label
			this.form.level = e[0].value
		},
		confirm2(e) {
			console.log(e);
			this.form.remindDate = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
			// this.form.levelN = e[0].label
			// this.form.level = e[0].value
		},
		async submit(){
			console.log(this.form)
			const res = await this.$api.AddMemorandum({'title':this.form.title,'content':this.form.content,'level':this.form.level,'remindDate':this.form.remindDate})
			console.log(res)
			if(res.code==1){
				uni.navigateBack()
			}else{
				this.$refs.uToast.show({
					title: res.msg,
					type: 'error'
				})
			}
		}
	}
};
</script>

<style>
</style>